package com.coocaa.aries.core.base.util;

import com.coocaa.aries.core.base.model.BaseQueryModel;
import com.coocaa.aries.core.tool.InstanceUtil;
import com.coocaa.aries.core.tool.reflect.ObjectMappingUtil;

import java.util.Map;

/**
 * @author bijiahao
 * @description
 * @date 2019/12/31 14:45
 */
public class PageQueryUtil {
    /**
     * 封装查询参数
     *
     * @param model
     * @return
     */
    public static Map<String, Object> getFilterMap(BaseQueryModel model) {
        Map<String, Object> params = InstanceUtil.newHashMap();
        ObjectMappingUtil.mappingObject2Map(model, params);
        //分页查询参数
        int offset = (model.getPage() - 1) * model.getRows();
        params.put("offset", offset);
        params.put("limit", model.getRows());
        return params;
    }
}
